#include "myview.h"
#include <QPainter>
#include <QDebug>
#include <QImage>

Myview::Myview(QObject *parent) : QStyledItemDelegate(parent)
{

}

void Myview::paint(QPainter *painter, const QStyleOptionViewItem &option,
                   const QModelIndex &index)const
{
//   qDebug()<<option.rect<<endl;
    //painter->drawLine(option.rect.topLeft(),option.rect.bottomRight());

    QVariant ret =index.data();
//    qDebug()<<ret<<endl;
    if(ret=="晴"){
        QImage image;
        if(image.load("d:/image/qnig.bmp")==false){
            qDebug()<<"加载图片失败"<<endl;
        }
        QRect r(option.rect.topLeft(),option.rect.bottomRight());
        painter->drawImage(r,image);
    }
    if(ret=="多云"){
        QImage image;
        if(image.load("d:/image/duoyun.png")==false){
            qDebug()<<"加载图片失败"<<endl;
        }
        QRect r(option.rect.topLeft(),option.rect.bottomRight());
        painter->drawImage(r,image);
    }
    if(ret=="小雨"){
        QImage image;
        if(image.load("d:/image/xaioyu.png")==false){
            qDebug()<<"加载图片失败"<<endl;
        }
        QRect r(option.rect.topLeft(),option.rect.bottomRight());
        painter->drawImage(r,image);
    }
    if(ret=="大雨"){
        QImage image;
        if(image.load("d:/image/zhongyu.bmp")==false){
            qDebug()<<"加载图片失败"<<endl;
        }
        QRect r(option.rect.topLeft(),option.rect.bottomRight());
        painter->drawImage(r,image);
    }
    if(ret=="中雨"){
        QImage image;
        if(image.load("d:/image/zhongyu.png")==false){
            qDebug()<<"加载图片失败"<<endl;
        }
        QRect r(option.rect.topLeft(),option.rect.bottomRight());
        painter->drawImage(r,image);
    }
    if(ret=="霾"){
        QImage image;
        if(image.load("d:/image/yin.bmp")==false){
            qDebug()<<"加载图片失败"<<endl;
        }
        QRect r(option.rect.topLeft(),option.rect.bottomRight());
        painter->drawImage(r,image);
    }
    if(ret=="阴"){
        QImage image;
        if(image.load("d:/image/yin.bmp")==false){
            qDebug()<<"加载图片失败"<<endl;
        }
        QRect r(option.rect.topLeft(),option.rect.bottomRight());
        painter->drawImage(r,image);
    }
}
